Constructing an agent that utilizes supplied rules and rules resident in an execution environment

ABSTRACT

A method for constructing an agent in an execution environment that utilizes a set of supplied canonical rules and a set of environment resident canonical rules comprising retrieving a first canonical rule set for the agent, retrieving a second canonical rule set for the agent and merging the two rule sets.

FIELD OF THE INVENTION

The present invention is generally related to software agents and moreparticularly to software agents' use of rule-based systems.

BACKGROUND OF THE INVENTION Agents

A software agent is a software abstraction, similar to theobject-oriented programming concept of an object. The concept of anagent provides a convenient and powerful way to describe a complexsoftware entity that is capable of acting with a certain degree ofautonomy in order to accomplish tasks on behalf of its user. But unlikeobjects, which are defined in terms of methods and attributes, an agentis defined in terms of its behavior.

Various authors have proposed different definitions of agents, commonlyincluding concepts such as:

-   -   Persistence—code is not executed on demand but runs continuously        and decides for itself when it should perform some activity    -   Autonomy—agents have capabilities of task selection,        prioritization, goal-directed behavior, decision-making without        human intervention    -   Social Ability—agents are able to engage other components        through communication and coordination, they may collaborate on        a task    -   Reactivity—agents perceive the context in which they operate and        react to it appropriately.

Agents may also be mobile. They can move from one execution environmentto another carrying both their code and their execution state. Theseexecution environments can exist in a variety of devices in a datanetwork including, but not limited to, servers, desktops, laptops,embedded devices, networking equipment and edge devices such as PDAs orcell phones. The characteristics of these platforms may vary widely interms of computational capacity, networking capacity, displaycapabilities, etc. An agent must be able to adapt to these conditions.

Historically, agents have been programmed in a procedural manner. Thatis, agents are programmed with a series of steps that will ultimatelyresult in a goal being achieved. This approach has limitations though asthe logic for each agent must be compiled into the agent software and istherefore static. Complex goals can also become intractable for aprogrammer as the set of rules the agent must follow grows.

Rule-Based Systems

In his tutorial, Introduction to Rule-Based Systems, JamesFreeman-Hargis defines a rule-based system to consist of a set ofassertions and a set of rules for how to act on the assertion set. Whena set of data is supplied to the system, it may result in zero or morerules firing. Rule based systems are rather simplistic in nature,consisting of little more than a group of if-then statements, but formthe basis of many “expert systems.” In an expert system, the knowledgeof an expert is encoded into the rule-set. When a set of data issupplied to the system, the system will come to the same conclusion asthe expert. With this approach there is a clear separation between thedomain logic (a rule set) and the execution of the agent. As mentioned,the procedural agent approach tightly couples the two.

The rule-based system itself uses a simple technique. It starts with arule-set, which contains all of the appropriate knowledge encoded intoIf-Then rules, and a working memory, which may or may not initiallycontain any data, assertions or initially known information. The systemin operation examines all the rule conditions (IF) and determines asubset, the conflict set, of the rules whose conditions are satisfiedbased on the working memory. Of this conflict set, one of those rules istriggered (fired). The rule that is chosen is based on a conflictresolution strategy. When the rule is fired, any actions specified inits THEN clause are carried out. These actions can modify the workingmemory, the rule-set itself, or do just about anything else the systemprogrammer decides to include. This loop of firing rules and performingactions continues until one of two conditions are met: there are no morerules whose conditions are satisfied or a rule is fired whose actionspecifies the rule engine execution should terminate.

Rule-based systems, as defined above, are adaptable to a variety ofproblems. In some problems, working memory asserted data is providedwith the rules and the system follows them to see where they lead. Thisapproach is known as forward-chaining. An example of this is a medicaldiagnosis in which the problem is to diagnose the underlying diseasebased on a set of symptoms (the working memory). A problem of thisnature is solved using a forward-chaining, data-driven, system thatcompares data in the working memory against the conditions (IF parts) ofthe rules and determines which rules to fire.

In other problems, a goal is specified and the system must find a way toachieve that specified goal. This is known as backward-chaining. Forexample, if there is an epidemic of a certain disease, this system couldpresume a given individual had the disease and attempt to determine ifits diagnosis is correct based on available information. Abackward-chaining, goal-driven, system accomplishes this. To do this,the system looks for the action in the THEN clause of the rules thatmatches the specified goal. In other words, it looks for the rules thatcan produce this goal. If a rule is found and fired, it takes each ofthat rule's conditions as goals and continues until either the availabledata satisfies all of the goals or there are no more rules that match.

The Rete algorithm is an efficient pattern matching algorithm forimplementing forward-chaining, rule-based systems. The Rete algorithmwas designed by Dr. Charles L. Forgy of Carnegie Mellon University in1979. Rete has become the basis for many popular expert systems,including JRules, OPS5, CLIPS, JESS, Drools, and LISA.

A naïve implementation of a rule-based system might check each ruleagainst the known facts in the knowledge base, firing that rule ifnecessary, then moving on to the next rule (and looping back to thefirst rule when finished). For even moderate sized rules and factknowledge-bases, this naïve approach performs far too slowly.

The Rete algorithm (usually pronounced either ‘REET’ or ‘REE-tee’, fromthe Latin ‘rete’ for net, or network) provides the basis for a moreefficient implementation of an expert system. A Rete-based expert systembuilds a network of nodes, where each node (except the root) correspondsto a pattern occurring in the left-hand-side of a rule. The path fromthe root node to a leaf node defines a complete rule left-hand-side.Each node has a memory of facts which satisfy that pattern.

As new facts are asserted or modified, they propagate along the network,causing nodes to be annotated when that fact matches that pattern. Whena fact or combination of facts causes all of the patterns for a givenrule to be satisfied, a leaf node is reached and the corresponding ruleis triggered.

The Rete algorithm is designed to sacrifice memory for increased speed.In most cases, the speed increase over naïve implementations is severalorders of magnitude (because Rete performance is theoreticallyindependent of the number of rules in the system). In very largesystems, however, the original Rete algorithm tends to run into memoryconsumption problems which have driven the design of Rete variants.

Therefore, what is needed is an ability to construct an agent with a setof supplied rules a set of rules retrieved from a local executionenvironment. More specifically what is needed is construction of anagent in which a set of supplied canonical rules is merged with a set ofrule retrieved from an execution environment.

SUMMARY OF THE INVENTION

The present invention provides a system, method, and computer readablemedium for constructing an agent that utilizes supplied rules and rulesresident in an execution environment.

In one embodiment of the present invention, a method for constructing anagent in an execution environment that utilizes a set of suppliedcanonical rules and a set of environment resident canonical rulescomprising retrieving a first canonical rule set for the agent,retrieving a second canonical rule set for the agent and merging thefirst and second rule sets. The method may also comprise the first ruleset being passed to or retrieved by the agent. The method mayadditionally comprise requesting the first rule set from a rulerepository. The method may further comprise the first rule set beingcomposed of agent goal specific canonical rules. The method may alsocomprise the agent retrieving the second rule set. Wherein the agentretrieves the second rule set, the method may also comprise retrievingthe second rule set from a rule repository in the execution environment.The method may additionally comprise the second rule set being composedof canonical rules. Wherein the second rule set is composed of canonicalrules, the method may further comprise the second rule set beingcomposed of domain and environment specific canonical rules. The methodmay also comprise the agent merging the first and second rule sets intoa merged rule set.

In another embodiment of the present invention, a computer readablemedium comprising instructions for requesting a first set of canonicalrules for an agent, retrieving a second set of canonical rules from anenvironment, merging the first and the second rule sets, compiling themerged rule set, creating a rule engine and passing the compiled ruleset to the rule engine. The computer readable medium may also compriseinstructions for retrieving the second set of canonical rules from arule repository. Wherein the second set of canonical rules is retrievedfrom a rule repository, the computer readable medium may additionallycomprise instructions for the rule repository residing in the executionenvironment in which the agent is being constructed. Wherein the secondset of canonical rules is retrieved from a rule repository, the computerreadable medium may further comprise instructions for the second ruleset being retrieved by supplying the agent's domain. The computerreadable medium may also comprise instructions for the agent merging thefirst and second rule sets into a merged rule set. Wherein the rule setsare merged, the computer readable medium may further compriseinstructions for constructing the merged rule set by taking the union ofthe first rule set and the second rule set. The computer readable mediummay also comprise instructions for compiling the merged rule set with arule compiler. The computer readable medium may additionally compriseinstructions for supplying the compiled, merged rule set to a ruleengine.

In a further embodiment of the present invention, a system of agentconstruction with two sets of canonical rules, comprising a first memoryand a first processor communicably coupled to the first memory, whereinthe processor retrieves a first canonical rule set for the agent,retrieves a second canonical rule set from the environment, merges thefirst and second rule sets into a merged canonical rule set, requestscompilation of the merged rule set, locates a rule engine, supplies therule engine with the compiled, merged rule set and requests a workingmemory from the rule engine. The system may also comprise storing thecanonical merged rule set, the compiled merged rule set and the workingmemory from the rule engine in the first memory. The system may furthercomprise a second memory which stores a rule repository that containscanonical rules for achieving goals and a second processor communicablycoupled to the second memory, wherein the second processor receives arule set query that include agent goals, retrieves an appropriatecanonical rule set based on the goals and sends a response containingthe rule set.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a diagram illustrating an exemplary process of constructing anagent locally with a set of canonical rules supplied duringconstruction;

FIG. 2 is a diagram illustrating an exemplary process of constructing anagent remotely with a set of canonical rules supplied duringconstruction;

FIG. 3 is a diagram illustrating an exemplary process of constructing anagent in a remote execution environment during which a set of canonicalrules is retrieved from outside the execution environment;

FIG. 4 is a diagram illustrating an exemplary process of moving an agentcarrying canonical rules from a first execution environment;

FIG. 5 is a diagram illustrating an exemplary process of moving an agentcarrying canonical rules to a second execution environment;

FIG. 6 is a diagram illustrating an exemplary process of an agentutilizing a rule-based system engine for execution;

FIG. 7 is a diagram illustrating an exemplary process of constructing anagent locally with a set of compiled rules supplied during construction;

FIG. 8 is a diagram illustrating an exemplary process of constructing anagent remotely with a set of compiled rules supplied duringconstruction;

FIG. 9 is a diagram illustrating an exemplary process of constructing anagent remotely during which a set of compiled rules that are retrievedfrom outside the execution environment;

FIG. 10 is a diagram illustrating an exemplary process of moving anagent carrying compiled rules from a first execution environment;

FIG. 11 is a diagram illustrating an exemplary process of moving anagent carrying compiled rules to a second execution environment;

FIG. 12 is a diagram illustrating an exemplary process of constructingan agent remotely with a set of canonical rules carried by the agent anda set of canonical execution environment rules resident in a remoteenvironment;

FIG. 13 is a diagram illustrating an exemplary process of constructingan agent remotely with a set of canonical rules fetched by the agent anda set of canonical execution environment rules resident in a remoteenvironment;

FIG. 14 is a diagram illustrating an exemplary process of moving anagent carrying canonical rules from a first execution environment thatincludes execution environment rules;

FIG. 15 is a diagram illustrating an exemplary process of moving anagent carrying canonical rules to a second execution environment thatincludes a repository of canonical execution environment rules;

FIG. 16 is a diagram illustrating an exemplary process of constructingan agent at a remote location with an as-needed set of canonical rulessupplied during construction;

FIG. 17 is a diagram illustrating an exemplary process of constructingan agent at a remote location with an as-needed set of canonical rulesfetched during construction;

FIG. 18 is a diagram illustrating an exemplary process of moving anagent with supplied as-needed canonical rules from a first executionenvironment;

FIG. 19 is a diagram illustrating an exemplary process of moving anagent with supplied as-needed canonical rules to a second executionenvironment;

FIG. 20 is a diagram illustrating an exemplary process of moving anagent from a first execution environment with a fetched as-needed set ofcanonical rules;

FIG. 21 is a diagram illustrating an exemplary process of moving anagent to a second execution environment with a fetched as-needed set ofcanonical rules;

FIG. 22 is a diagram illustrating an exemplary process of a rule-basedagent updating rule history when rule processing is halted in anexecution environment;

FIG. 23 is a diagram illustrating an exemplary process of a rule-basedagent identifying and carrying only needed canonical rules during aspart of movement to another execution environment;

FIG. 24 is a diagram illustrating an exemplary process of an agent usinga set of survival rules to determine its lifespan; and

FIG. 25 is a diagram illustrating an exemplary process of an agent usinga set of data narrowing rules to determine how much data should be sentover the network.

DETAILED DESCRIPTION OF THE INVENTION Construction

Agents which utilize rule based systems may be constructed locally orremotely. In order to operate, these agents need an initial set ofcanonical rules that can be compiled and loaded into an associated ruleengine. These rules can either be supplied at construction or a rulerepository location can be supplied so that the rules may be fetchedduring construction or at a later time.

Referring now to FIG. 1, a diagram illustrating an exemplary process ofconstructing an agent locally with a set of canonical rules suppliedduring construction is shown. An application 110, in an executionenvironment 112, requests a set of rules for an agent from a rulerepository 116 based on the goals of the agent that is being created.The result is a collection of canonical rules, known as a rule set 118.The rule set 118 is passed to the agent 120 during construction. Theagent 120 takes the rule set 118 and requests that it be compiled by thelocal rule compiler 122. This results in the creation of a compiled ruleset 124. At this point the agent creates the rule engine 126 that willbe used to execute the rule set. Note that if the execution environment112 includes a rule engine, then one may not need to be created. Afterthe rule engine 126 is created or located, the agent 120 supplies theengine 126 with the compiled rule set 124. Finally, the agent 120requests a new working memory 128 from the rule engine 126. The workingmemory will hold all of the data the agent chooses to assert before andduring execution of the rule engine. At this point, the agent 120 isready to be moved to another execution environment or to execute therule engine. Both of these processes are described in detail in latersections.

Referring now to FIG. 2, a diagram illustrating an exemplary process ofconstructing an agent remotely with a set of canonical rules suppliedduring construction is shown. An application 218, in executionenvironment 212, requests a set of rules for an agent from a rulerepository 220 in execution environment 214 based on the goals of theagent that is being created. The result is a collection of canonicalrules, known as a rule set 222. The rule set 222 is passed to the agent224 during construction in execution environment 216. The agent 224 inexecution environment 216 takes the rule set 222 and requests that it becompiled by the local rule compiler 226. This results in the creation ofa compiled rule set 228. At this point the agent creates the rule engine230 that will be used to execute the rule set. Note that if executionenvironment 216 includes a rule engine, then one may not need to becreated. After the rule engine 230 is created or located, the agent 224supplies the engine 230 with the compiled rule set 228. Finally, theagent 224 requests a new working memory 232 from the rule engine 230.The working memory will hold all of the data the agent chooses to assertbefore and during execution of the rule engine. At this point, the agent224 is ready to be moved to another execution environment or to executethe rule engine.

Referring now to FIG. 3, a diagram illustrating an exemplary process ofconstructing an agent in a remote execution environment during which aset of canonical rules is retrieved from outside the executionenvironment is shown. An application 318, in execution environment 312,requests the creation of an agent 324 in execution environment 316.Agent 324 is passed the location of a rule repository 320 duringconstruction. During construction, the agent 324 requests a set of rulesbased on its goals from the rule repository 320 in execution environment314. The result is a collection of canonical rules, known as a rule set322. The agent 324 in execution environment 316 takes the rule set 322and requests that it be compiled by the local rule compiler 326. Thisresults in the creation of a compiled rule set 328. At this point theagent creates the rule engine 330 that will be used to execute the ruleset. Note that if execution environment 314 includes a rule engine, thenone may not need to be created. After the rule engine 330 is created orlocated, the agent 324 supplies the engine 330 with the compiled ruleset 328. Finally, the agent 324 requests a new working memory 332 fromthe rule engine 330. The working memory will hold all of the data theagent chooses to assert before and during execution of the rule engine.At this point, the agent 324 is ready to be moved to another executionenvironment or to execute the rule engine.

Movement

An agent may move from one execution environment to another. Thisprocess may be initiated by a variety of means including but not limitedto an application, another agent, another object, the existing agentitself, a human interacting with the execution environment or a ruleexecuting in the agent's rule engine.

Referring now to FIGS. 4 and 5, diagrams illustrating an exemplaryprocess of moving an agent carrying canonical rules from one executionenvironment to another are shown. An application 418 in executionenvironment 412 requests that an agent 424 in execution environment 414move to execution environment 416. The location of execution environment416 may be described in the move request by an IP address and port,Uniform Resource Locator (URL), or any other means of addressing. Theagent 424 discards its rule engine 430 along with the associatedcompiled rule set 428 and working memory 432. The agent 424 then encodesitself along with its canonical rule set 422 into a transferable form434. Though a byte array is shown, the encoded agent could take any formthat can be transferred between the two execution environments. Once theagent 424 has created an encoded version of itself 434 in executionenvironment 414 it transfers the encoded version 434 to an agent manager426 residing in execution environment 416.

Referring now to FIG. 5, the process continues with the agent manager522 receiving the encoded agent 534. Upon receipt of the encoded agent534, the agent manager 522 decodes the encoded agent 534 into a newversion of the agent 524 and the agent's canonical rule set 526 inexecution environment 516. Once the agent 524 and rule set 526 have beenmaterialized, the agent manager 522 requests that the agent 524initialize. This request prompts the agent 524 to go to the executionenvironment's rule compiler 520 and request compilation of its canonicalrule set 526. The result is a compiled rule set 528. The agent thencreates a new rule engine 530 and subsequently passes the compiled ruleset 528 to it. As during construction, if the execution environment hasa rule engine, then one may not need to be created. Once the engine 530has been located/created and the compiled rule set 528 has been added toit, the agent 524 requests a new working memory from the rule engine. Asbefore, the working memory will hold all of the data the agent choosesto assert before and during execution of the rule engine. At this point,the agent 524 is ready to execute the rule engine. Once the moveoperation completes, the old version of the agent 518 in executionenvironment 514 indicates to the requesting application 518 in executionenvironment 512 that the move operation has completed. Once thenotification has been made, the old agent 534 is destroyed.

Execution

Once an agent has been initialized in an execution environment througheither creation or movement, it can be sent requests to performdifferent tasks. These tasks may or may not require sending one or moreresponses. Recall that during construction an agent is associated with anewly created or resident rule engine and that a rule set is provided tothat engine.

Referring now to FIG. 6, a diagram illustrating an exemplary process ofan agent utilizing a rule-based system engine for execution is shown. Anapplication 616 in execution environment 612 sends a request to an agent618 in execution environment 614. Upon receiving the request, the agent618, collects an initial set of data and asserts it into its workingmemory 624 in order to accomplish the task requested. Note that thisdata may be collected from the local execution environment, from anaccessible database, from other objects, from other agents, from a humanvia a man machine interface, from a computer readable medium or anycombinations of the above. With a provided compiled rule set 620, and aninitial set of data in working memory 624, the rule engine 622 is thenstarted by the agent 618.

When the engine 622 starts, it processes the objects in working memoryagainst the rule set 620. This may result in one or more rules beingfired by the engine 622. When a rule is fired it may add, modify ordelete objects in working memory 624. Additionally, the engine 622 caninform the agent 618 which may result in a number of actions being takenby the agent 618 including, but not limited to, the collection andassertion of additional data into the working memory 624 (shown) and/orsending of a preliminary response back to the application. This sequencewill continue until the task is completed, there are no more rulesavailable to fire, or the agent receives an event, such as move orterminate, causing it to halt rule engine processing. Upon completion ofthe task, the agent 618 may send a response back to the application 616that initiated the request (shown).

Pre-Compiled Agent Rule Set Usage

As noted above, the process of adding rules to the rule engine can beexpensive in terms of CPU utilization on the execution environment inwhich the operation is performed. This can be problematic for lesspowerful hosts such as personal devices (cell phones, PDAs, etc.) andservers with limited available CPU resources. Therefore, anotherembodiment of the invention creates the compiled rule set in theexecution environment of the application that creates an agent insteadof in the environment in which the agent is constructed or moved.

Referring now to FIG. 7, a diagram illustrating an exemplary process ofconstructing an agent locally with a set of compiled rules suppliedduring construction is shown. An application 712, in executionenvironment 714, requests a set of rules for an agent from a rulerepository 720 based on the goals of the agent that is being created.The result is a collection of canonical rules, known as a rule set 724.The application 712 takes the rule set 724 and requests that it becompiled by the local rule compiler 722. This results in the creation ofa compiled rule set 724. The rule set 724 is passed to the agent 718during construction. At this point the agent creates the rule engine 726that will be used to execute the rule set. Note that if the executionenvironment 714 includes a rule engine, then one may not need to becreated. After the rule engine 726 is created or located, the agent 722supplies the engine 726 with the compiled rule set 724. Finally, theagent 110 requests a new working memory 728 from the rule engine 726.The working memory will hold all of the data the agent chooses to assertbefore and during execution of the rule engine. At this point, the agent718 is ready to be moved to another execution environment or to executethe rule engine.

Referring now to FIG. 8, a diagram illustrating an exemplary process ofconstructing an agent remotely with a set of compiled rules suppliedduring construction is shown. An application 812, in executionenvironment 814, requests a set of rules for an agent from a rule server828 in execution environment 818 based on the goals of the agent that isbeing created. The rule server 828 queries a rule repository 830 for therules. The result is a collection of canonical rules, known as a ruleset 832. The rule server 828 in execution environment 202 takes the ruleset 832 and requests that it be compiled by the local rule compiler 834.This results in the creation of a compiled rule set 826. The compiledrule set 826 is passed to the agent 820 during construction in executionenvironment 204. At this point, the agent 820 creates the rule engine822 that will be used to execute the rule set. Note that if executionenvironment 816 includes a rule engine, then one may not need to becreated. After the rule engine 822 is created or located, the agent 820supplies the engine 822 with the compiled rule set 826. Finally, theagent 820 requests a new working memory 116 from the rule engine 822.The working memory will hold all of the data the agent chooses to assertbefore and during execution of the rule engine. At this point, the agent820 is ready to execute the rule engine.

Referring now to FIG. 9, a diagram illustrating an exemplary process ofconstructing an agent in a remote execution environment during which aset of compiled rules is retrieved from outside the executionenvironment is shown. An application 912, in execution environment 914,requests the creation of an agent 920 in execution environment 916.Agent 920 is passed the location of a rule server 928, resident inexecution environment 918, during construction. During construction, theagent 920 requests a set of compiled rules based on its goals from therule server 928 in execution environment 918. The rule server 928queries a rule repository 930 for a set of rules. The result is acollection of canonical rules, known as a rule set 932. The rule server928 in execution environment 918 takes the rule set 932 and requeststhat it be compiled by the local rule compiler 934. This results in thecreation of a compiled rule set 926. At this point the agent 920 createsa rule engine 922 that will be used to execute the rule set. Note thatif execution environment 916 includes a rule engine, then one may notneed to be created. After the rule engine 922 is created or located, theagent 920 supplies the engine 922 with the compiled rule set 926.Finally, the agent 920 requests a new working memory 924 from the ruleengine 922. The working memory will hold all of the data the agentchooses to assert before and during execution of the rule engine. Atthis point, the agent 920 is ready to execute the rule engine.

Referring now to FIGS. 10-11, diagrams illustrating an exemplary processof moving an agent carrying compiled rules from one executionenvironment to another are shown. An application 1018 in executionenvironment 1012 request that an agent 1022 in execution environment1014 move to execution environment 1016. The location of executionenvironment 1016 may be described in the move request by an IP addressand port, Uniform Resource Locator (URL), or any other means ofaddressing. The agent 1022 discards its rule engine 1030 along with theassociated working memory 1032. Subsequently, the agent 1022 discardsits canonical rule set 1020 if it still has a reference to it. The agent1022 then encodes itself along with its compiled rule set 1028 into atransferable form 1024. Though a byte array is shown, the encoded agentcould take any form that can be transferred between the two executionenvironments. Once the agent 1022 has created an encoded version ofitself 1024 in execution environment 1014 it transfers the encodedversion 1024 to an agent manager 1026 residing in execution environment1016.

Referring now to FIG. 11, the process continues with an agent manager1122 receiving an encoded agent 1134. Upon receipt of the encoded agent1134, the agent manager 1122 decodes the encoded agent 1134 into a newversion of the agent 1124 and its compiled rule set 1128 in executionenvironment 1116. Once the agent 1124 and rule set 1128 have beendecoded, the agent manager 1122 requests that the agent 1124 initialize.This request prompts the agent 1124 to create a new rule engine 1130 andsubsequently pass the compiled rule set 1128 to it. As duringconstruction, if the execution environment has a rule engine, then onemay not need to be created. Once the engine 1130 has beenlocated/created and the compiled rule set 1128 has been added to it, theagent 1124 requests a new working memory 1132 from the rule engine. Asbefore, the working memory will hold all of the data the agent choosesto assert before and during execution of the rule engine. At this point,the agent 1124 is ready to execute the rule engine. Once the moveoperation completes, the old version of the agent 1118 in executionenvironment 1114 indicates to the requesting application 1118 inexecution environment 1112 that the move operation has completed. Oncethe notification has been made, the old agent 1118 is destroyed.

Execution Environment Rule Set Usage

Each execution environment may have access to a local rule repositorywhich allow for the rules for a particular domain, domain rules, to bedistributed, or partitioned, in any number of rule repositories. Anagent may be configured to only use rules provided at constructionessentially ignoring rules available from each execution environment'slocal rule repository. The more general case is for the agent to makeuse of the rules that it carries with itself along with the rulesextracted from the execution environment's local rule repository. Localrule repositories may contain rules for several different domains andare usually specific to execution environment objects that will beasserted to working memory but may also apply to execution environmentconcerns such as security, resource usage, scheduling, or any otherexecution environment attribute.

Referring now to FIG. 12, a diagram illustrating an exemplary process ofconstructing an agent remotely with a set of canonical rules carried bythe agent and a set of canonical rules resident in a remote environmentis shown. An application 1218, in execution environment 1212, requests aset of rules for an agent from a rule repository 1220 in executionenvironment 1214 based on the goals of the agent that is being created.The result is a collection of canonical rules, known as a rule set 1230.The rule set 1230 is passed to the agent 1232 during construction inexecution environment 1216. During construction, the agent 1232 requeststhe set of rules from a local rule repository 1234 given the agent'sdomain (not shown). The result of which, canonical rule set 1236, isthen merged with the construction supplied rule set 1230 to form amerged rule set 1222. This rule set contains all the domain andenvironment specific rules that the agents' rule engine will execute.The agent 1232 then takes the merged rule set 1222 and requests that itbe compiled by the local rule compiler 1226. This results in thecreation of a compiled rule set 1238. At this point the agent creates arule engine 1224 that will be used to execute the rule set 1238. Notethat if execution environment 1216 includes a rule engine, then one maynot need to be created. After the rule engine 1224 is created orlocated, the agent 1232 supplies the engine 1224 with the compiled ruleset 1238. Finally, the agent 1232 requests a new working memory 1228from the rule engine 1224. The working memory will hold all of the datathe agent chooses to assert before and during execution of the ruleengine.

Referring now to FIG. 13, a diagram illustrating an exemplary process ofconstructing an agent remotely with a set of canonical rules fetched bythe agent and a set of canonical local rules resident in a remoteenvironment is shown. An application 1318, in execution environment1312, requests the creation of an agent 1332 in execution environment1316. Agent 1332 is passed the location of a rule repository 1320 duringconstruction. During construction, the agent 1332 requests a set ofrules based on its goals from the rule repository 1320 in executionenvironment 1314. The result is a collection of canonical rules, knownas a rule set 1330. During construction, the agent 1332 requests the setof rules from a local rule repository 1334 that apply to its domain. Theresult of which, canonical rule set 1336, is then merged with thefetched rule set 104 to form a merged rule set 1322. This rule setcontains all the domain and environment specific rules that the agents'rule engine will execute. The agent 1332 then takes the merged rule set1322 and requests that it be compiled by the local rule compiler 1326.This results in the creation of a compiled rule set 1338. At this pointthe agent creates a rule engine 1324 that will be used to execute therule set 1338. Note that if execution environment 1316 includes a ruleengine, then one may not need to be created. After the rule engine 1324is created or located, the agent 1332 supplies the engine 1324 with thecompiled rule set 1338. Finally, the agent 1332 requests a new workingmemory 1328 from the rule engine 1324. The working memory will hold allof the data the agent chooses to assert before and during execution ofthe rule engine.

Referring now to FIGS. 14-15, diagrams illustrating an exemplary processof moving an agent carrying canonical rules to an execution environmentthat includes a local repository of canonical rules are shown. Referringnow to FIG. 14, an application 1418 in execution environment 1412requests that an agent 1422 in execution environment 1414 move toexecution environment 1416. The location of execution environment 1416may be described in the move request by an IP address and port, UniformResource Locator (URL), or any other means of addressing. The agent 1422discards its rule engine 1430 along with the associated compiled ruleset 1428 and working memory 1432. The agent 1422 then encodes itselfalong with its canonical rule set 1420 into a transferable form 1424.Though a byte array is shown, the encoded agent could take any form thatcan be transferred between the two execution environments. Once theagent 1422 has created an encoded version of itself 1424 in executionenvironment 1414 it transfers the encoded version 1424 to an agentmanager 1426 residing in execution environment 1416.

Referring now to FIG. 15, the process continues with the agent manager1522 receiving the encoded agent 1534. Upon receipt of the encoded agent1534, the agent manager 1522 decodes the encoded agent 1534 into a newagent 1526 and its canonical rule set 1540 in execution environment1516. Once the agent 1526 and rule set 1540 have been decoded, the agentmanager 1522 requests that the agent 1526 initialize. This requestprompts the agent 1526 to request the set of rules applicable to theagent's domain from a local rule repository 1536. The result of which,canonical rule set 1538, is then merged with the carried rule set 1540to form a merged rule set 1534. This rule set contains all the domainand environment specific rules that the agents rule engine will execute.The agent 1526 then takes the merged rule set 1534 and requests that itbe compiled by the local rule compiler 1524. The result is a compiledrule set 1528. The agent then creates a new rule engine 1530 andsubsequently passes the compiled rule set 1528 to it. As duringconstruction, if the execution environment has a sharable rule engine,then one may not need to be created. Once the engine 1530 has beenlocated/created and the compiled rule set 1528 has been added to it, theagent 1526 requests a new working memory 1532 from the rule engine. Asbefore, the working memory will hold all of the data the agent choosesto assert before and during execution of the rule engine. Once the moveoperation completes, the old version of the agent 1520 in executionenvironment 1514 indicates to the requesting application 1518 inexecution environment 1512 that the move operation has completed. Oncethe notification has been made, the old agent 1520 is destroyed.

As-Needed Rules

As there is a cost of carrying around unnecessary rules in terms of bothCPU and memory usage, it is desirable in many cases to supply an agentwith a subset of its total potential rule set. This can be done in acontext-specific manner based on the goals and execution environment ofthe agent. For example, if each device upon which an agent will beexecuting only contains a small screen, then there is no need to carrythe rules for display on a standard computer monitor. As anotherexample, an agent who moves progressively further in a single direction,perhaps among GPS enabled fixed location devices, need not carry rulesthat only apply to previous GPS locations.

Referring now to FIG. 16, a diagram illustrating an exemplary process ofconstructing an agent at a remote location with an as-needed set ofcanonical rules supplied during construction is shown. An application1618, in execution environment 1612, requests a set of rules for anagent from a rule repository 1620 in execution environment 1614 based onthe goals and initial execution environment of the agent that is beingcreated. When supplied with a target execution environment, the rulerepository 1620 can filter out rules that do not apply to that type ofenvironment. The result is a collection of canonical rules, known as arule set 1622. The rule set 1622 is passed to the agent 1624 duringconstruction in execution environment 1616. The agent 1624 in executionenvironment 1616 takes the rule set 1622 and requests that it becompiled by the local rule compiler 1626. This results in the creationof a compiled rule set 1628. At this point the agent creates the ruleengine 1630 that will be used to execute the rule set. Note that ifexecution environment 1616 includes a rule engine, then one may not needto be created. After the rule engine 1630 is created or located, theagent 1624 supplies the engine 1630 with the compiled rule set 1628.Finally, the agent 1624 requests a new working memory 1632 from the ruleengine 1630. The working memory will hold all of the data the agentchooses to assert before and during execution of the rule engine. Atthis point, the agent 1624 is ready to be moved to another executionenvironment or to execute the rule engine.

Referring now to FIG. 17, a diagram illustrating an exemplary process ofconstructing an agent at a remote location with an as-needed set ofcanonical rules fetched during construction is shown. An application1718, in execution environment 1712, requests the creation of an agent1724 in execution environment 1716. Agent 1724 is passed the location ofa rule repository 1720 during construction. During construction, theagent 1724 requests a set of rules based on its goals and executionenvironment from the rule repository 1720 in execution environment 1714.When supplied with the target execution environment, the rule repository1720 can filter out rules that do not apply to that type of environment.The result is a collection of canonical rules, known as a rule set 1722.The agent 1724 in execution environment 204 takes the rule set 1722 andrequests that it be compiled by the local rule compiler 1726. Thisresults in the creation of a compiled rule set 1728. At this point theagent creates the rule engine 1730 that will be used to execute the ruleset. Note that if execution environment 1714 includes a rule engine,then one may not need to be created. After the rule engine 1730 iscreated or located, the agent 1724 supplies the engine 1730 with thecompiled rule set 1728. Finally, the agent 1724 requests a new workingmemory 1732 from the rule engine 1730. The working memory will hold allof the data the agent chooses to assert before and during execution ofthe rule engine. At this point, the agent 1724 is ready to be moved toanother execution environment or to execute the rule engine.

Referring now to FIGS. 18-19, diagrams illustrating an exemplary processof moving an agent from one execution environment to another with asupplied as-needed set of canonical rules are shown. An application 1818in execution environment 1812 requests that an agent 1822 in executionenvironment 1814 move to execution environment 1816. The location ofexecution environment 1816 may be described in the move request by an IPaddress and port, Uniform Resource Locator (URL), or any other means ofaddressing. The move request includes a new as-needed canonical rule set1834 based on the agent's goals and target execution environment. Theagent 1822 discards its rule engine 1830 along with the associatedcompiled rule set 1828 and working memory 1832. In addition the agent1822 discards its old canonical rule set 1820. At this point, the agent1822 encodes itself along with its new as-needed canonical rule set 1834into a transferable form 1824. Though a byte array is shown, the encodedagent could take any form that can be transferred between the twoexecution environments. Once the agent 1822 has created an encodedversion of itself 1824 in execution environment 1814 it transfers theencoded version 1824 to an agent manager 1826 residing in executionenvironment 1816.

Referring now to FIG. 19, the process continues with the agent manager1922 receiving an encoded agent 1934. Upon receipt of the encoded agent1934, the agent manager 118 decodes the encoded agent 1934 into a newversion of the agent 1924 and its new canonical rule set 1926 inexecution environment 1916. Once the agent 1924 and rule set 1926 havebeen materialized, the agent manager 1922 requests that the agent 1922initialize. This request prompts the agent 1922 to go to the executionenvironments' rule compiler 1920 and request compilation of itscanonical rule set 1926. The result is a compiled rule set 1928. Theagent then creates a new rule engine 1930 and subsequently passes thecompiled rule set 1928 to it. As during construction, if the executionenvironment has a rule engine, then one may not need to be created. Oncethe engine 1928 has been located/created and the compiled rule set 1926has been added to it, the agent 1922 requests a new working memory fromthe rule engine. As before, the working memory will hold all of the datathe agent chooses to assert before and during execution of the ruleengine. Once the move operation completes, the old version of the agent1918 in execution environment 1914 indicates to the requestingapplication 1918 in execution environment 1912 that the move operationhas completed. Once the notification has been made, the old agent 1934is destroyed.

Referring now to FIGS. 20-21, diagrams illustrating an exemplary processof moving an agent from one execution environment to another with afetched as-needed set of canonical rules are shown. An application 2018in execution environment 2012 requests that an agent 2022 in executionenvironment 2014 move to execution environment 2016. The location ofexecution environment 2016 may be described in the move request by an IPaddress and port, Uniform Resource Locator (URL), or any other means ofaddressing. The move request includes a reference to a rule repository2038 from which the agent should fetch a new as-needed rule set. Uponreceiving the move request, the agent 2022 requests a new as-needed ruleset from the supplied rule repository 2038 based on its goals and targetexecution environment 2016. After receiving the new canonical rule set2034, the agent 2022 discards its rule engine 2030 along with theassociated compiled rule set 2028 and working memory 2032. In additionthe agent 2022 discards its old canonical rule set 2020. At this point,the agent 2022 encodes itself along with its new as-needed canonicalrule set 2034 into a transferable form 2024. Though a byte array isshown, the encoded agent could take any form that can be transferredbetween the two execution environments. Once the agent 2022 has createdan encoded version of itself 2024 in execution environment 2014 ittransfers the encoded version 2024 to an agent manager 2026 residing inexecution environment 2016.

Referring now to FIG. 21, the process continues with the agent manager2122 receiving an encoded agent 2134. Upon receipt of the encoded agent2134, the agent manager 2122 decodes the encoded agent 2134 into a newversion of the agent 2124 and its new canonical rule set 2126 inexecution environment 204. Once the agent 2124 and rule set 124 havebeen materialized, the agent manager 2122 requests that the agent 2124initialize. This request prompts the agent 2124 to go to the executionenvironment's rule compiler 2120 and request compilation of itscanonical rule set 2126. The result is a compiled rule set 2128. Theagent then creates a new rule engine 130 and subsequently passes thecompiled rule set 2128 to it. As during construction, if the executionenvironment has a sharable rule engine, then one may not need to becreated. Once the engine 2130 has been located/created and the compiledrule set 2126 has been added to it, the agent 2124 requests a newworking memory from the rule engine. As before, the working memory willhold all of the data the agent chooses to assert before and duringexecution of the rule engine. Once the move operation completes, the oldversion of the agent 2138 in execution environment 2114 indicates to therequesting application 2118 in execution environment 2112 that the moveoperation has completed. Once the notification has been made, the oldagent 2138 is destroyed.

Dynamic Determination Of Needed Rules

Large rule sets, even with efficient algorithms such as Rete, are oftenexpensive in computation and bandwidth. The process of dynamicallyremoving rules considered unlikely to be useful has a benefit toperformance and also, combined with mobile agents, provides an efficientmethod for utilizing large rule sets that can be partitioned across manyrepositories. This method also allows an agent to dynamically change therules to meet the execution environment processing task.

Each constructed agent has a unique identifier for itself and thisidentifier is also known to the agent's originator. At the point oforigination, this identifier will be associated with the agent'soutcome. An example outcome is successfully attaining an end goal andsending the results back to the application. Another example outcome isthe loss or death of the agent. An agent that is determined to be lostor dead may cause a replacement agent to be launched. The replacementagent will have a unique identifier that differs from the originalagent. In addition to a unique agent identifier, an agent also carrieswith it an indicative subset of the set of previously completed agentoutcomes for the given domain. This is a set of unique identifiers andoutcomes for agents that have previously executed in the domain of thecurrent agent.

In each execution environment, the local rule repository not only storesrules, but is also the location for agents to record statistics aboutrule engine activity for the rules in the rule set given to the ruleengine. These instrumented rules include agent carried rules and rulesfor the domain that were retrieved from the local rule repository.Alternately, only the locally acquired domain rules may be instrumented.

Referring now to FIG. 22, a diagram illustrating an exemplary process ofa rule-based agent updating rule statistics when rule processing hascompleted in an execution environment is shown. As before, an agent 2218starts its associated rule engine 2222 to process its compiled rule set2220. During the course of execution, the rule engine 2222 maysuccessfully match part of the condition (left hand side) of a rule, maymatch the condition of a rule and activate it, or may match and activateand fire a rule (perform the consequences of the rule). A rule enginemay provide for collection of the statistics for the phases of ruleactivity mentioned. Alternately, the agent may integrate listener codeto monitor these phases of rule execution and collect the statistics asthe rule engine executes. A rule being fired may result in the ruleasserting new data into the working memory 2224 and/or the agent 2218collecting more data and asserting that into the working memory 2224.Once an end goal terminates rule processing, or the agent receives amove event, a termination event, a timeout or some other event, then therule engine is halted. At this point, the agent 2218 requests rulestatistics from the rule engine 2222 or collects the statistics from theagent's rule engine listener. These statistics may include, but are notlimited to the number of times a rule was fired, the number of times arule was activated, the number of times a goal in the condition of arule was matched, the number of times a part of the condition of a rulewas matched, or any combination of the above. The statistics 2226 arethen added to aggregate rule history stored in the local rule repository2216. These stored statistics may include statistics for rules that arenot available in the local rule repository since an agent can carryrules with it as it moves.

When the agent prepares to move to another execution environment itdynamically determines to remove unnecessary rules by consulting therule history associated with some or all of the rules in its currentrule set in conjunction with the indicative subset of previouslycompleted agent outcomes that the agent carries. Referring now to FIG.23, a diagram illustrating an exemplary process of a rule-based agentdynamically removing unnecessary rules as part of movement to anotherexecution environment is shown. An application 2318 requests that anagent 2326 in execution environment 2314 move to execution environment2316. The agent 2326 requests a set of rules from the local rulerepository 2322 that are allowed to be carried to other platforms. Theresult is a canonical rule set 2334. This rule set is then merged withthe set of rules 2320 that the agent 2326 carried with it to executionenvironment 2314. The result is canonical rule set 2336.

At this point the agent consults the local rule repository 2322 to getthe rule history 2330 of the rules in set 2336. The agent 2326 then usesthe rule history 2330 with its carried set of previous agent outcomes toremove rules from rule set 116 that are unlikely to participate in adesired outcome. The statistics are used in aggregate form. As anexample consider an agent that carries the results of 2318 previouslyexecuted agents and their outcomes, 50 of which were desirable outcomes.The agent examines the metrics for a particular rule named “A” whichshows that it was never activated. The agent then removes rule “A” fromits agent carried rule set. As another example consider rule “B” whichhas been activated and fired in one-third of previous desirable outcomesbut also has been active and fired in nearly all negative outcomes. Rule“B” remains in the agent carried rule set. Finally, a rule, “C”, whichnever activates for any as yet recorded desired outcomes but has beenactive in almost all negative outcomes can be considered a computationalburden and removed from the agent carried rule set. Although activationis a criterion above, finer grained partial left-hand side matchingstatistics can be used as well. Since rule removal requires an aggregateof previous runs a threshold is provided so that no rule deletion ispermitted until a requisite number of outcomes has been obtained.

Once the pruned rule set 2332 has been created, the agent 2326 encodesitself along with its pruned rule set 2332 into a transferable form inexecution environment 2314. The agent 2326 then transfers the encodedversion of itself in execution environment 2314 to an agent manager 2346resident in the target execution environment 2316. The remainder of themove process follows that of FIG. 5.

Survivability Rules

All agents have a lifespan; but that lifespan need not be pre-determinedif a set of rules around survivability of an agent is put in place.These rules may be agent specific or execution environment specific.They may be carried with the agent or resident in a rule repository forthe execution environment. As these rules are like any other declarativerules, they may be any combination of the above according to theteachings of this invention. In addition, these rules may be used inconjunction with more typical survivability mechanisms such asheartbeats between the application and the agent.

Referring now to FIG. 24, a diagram illustrating an exemplary process ofan agent using a set of survival rules to determine its lifespan isshown. Agent survivability is controlled by the rules loaded in thelocal compiled rule set 2428. As before, the local rule set may becomprised of rules supplied or fetched from rule repository 2420 duringconstruction, rules carried from other visited execution environmentsand/or execution environment specific rules retrieved from rulerepository 2426. Many sources of data that may be asserted into theworking memory and, combined with the local rule set 2428, affect theagent's 2424 lifespan. Examples include lifespan update events fromapplication 2418, heartbeat events from application 2418, timer eventsfrom the execution environment's timer system 2434, and even statechange events from the agent 2424 itself. As data is asserted into theworking memory, the rules engine guarantees that applicable rules arefired. Any number of rules might result in the agent 2424 taking actionsthat affect its survivability. This includes death of the agent 2424which is shown. When an agent 104 dies it halts rule engine processing,records any collected historical statistics for the local rule set andstores these in the rule repository 2436.

Data Narrowing Rules

Agent may visit many execution environments each with differing levelsof network connectivity or an execution environment with multiplelevels/types of network connectivity. Given this, it is important thatan agent take this into consideration when responding to applicationrequests, sending periodic reports, and determining how much data tocarry with it when moving. As per the teachings of this invention,execution environment specific rules are an ideal method for insuringthe appropriate agent behavior. If the networking capabilities of theexecution environment are static, then rules for this may be maintainedin the rule repository on the execution environment running theapplication that launched the agent. In many cases though, thecapabilities may be more dynamic in which case the rules regardingnetwork bandwidth are better kept on the remote execution environment.

Referring now to FIG. 25, a diagram illustrating an exemplary process ofthe of an agent using a set of data narrowing rules to determine howmuch data should be sent over the network is shown. This diagram showsthe same agent in three different scenarios. As before, each agent iscommunicating with an application 2532 that in this case is hosted onserver 2530 which is connected to a high-speed data network, 2534. Inthe first scenario, the agent 2514 has been constructed on or moved toserver execution environment 2512, which is connected to the high speeddata network directly via a gigabit ethernet link 2544. The agent 2514utilized a rule-based system that is driven by the associated ruleengine 2516. This engine 2516 has been loaded with execution environmentspecific rules about the current network bandwidth capabilities of theexecution environment 2512. In this example the agent 106 completes atask which will ultimately generate a report back to the application2532 on execution environment 2530. When that task completes, that eventcauses a rule to fire in the engine 2516, which instructs the agent 2514to send a detailed report. In this case, a detailed report isappropriate because a high bandwidth connection is available between theagent 2514 and the application 2532.

In the second scenario, that same agent now labeled 114 has moved to ahome computer 2518 which is connected to the network via a DSLconnection 2546. As before, the engine 2522 is loaded with the executionenvironment specific rules regarding bandwidth available to theexecution environment. As the agent 2520 completes its task, the eventcauses a rule to fire, which instructs agent 2520 to send a full report,which contains less data than the detailed report described previously.Note, that the agent 2520 is not compressing the same data, but sendinga different data-set back—a subset of the data to fit the bandwidthavailable.

In the final scenario, the agent, now labeled 2526 has moved to themobile device 2524. The mobile device is connected to the high speeddata network via a relatively low speed cellular data network 2536. Asbefore, the agent 2526 completes its task which results in the ruleengine 2528 firing a rule. This firing causes the agent 2526 to dispatcha much smaller summary report to the application 2532 in order toaccommodate the low bandwidth connection.

Methods, computer readable media and systems have been shown and/ordescribed in the above embodiments for constructing an agent thatutilizes supplied rules and rules resident in an execution environment.Although the above descriptions set forth embodiments, it will beunderstood that there is no intent to limit the invention by suchdisclosure, but rather, it is intended to cover all modifications andalternate implementations falling within the spirit and scope of theinvention. For example, the present invention should not be limited to asingle agent, or to a particular programming language for the executionenvironment. Furthermore, the association of agent to executionenvironments is not limited to the topology depicted. Lastly, theembodiments are intended to cover capabilities and concepts whether theybe via a loosely couple set of components or they be converged into oneor more integrated components, devices, circuits, and/or softwareprograms.

1. A device-implemented method comprising: retrieving a first canonicalrule set for an agent; constructing the agent in an executionenvironment embodied on a device utilizing the first canonical rule set,the constructing causing a request for a second canonical rule set forthe agent from the execution environment; and causing the agent to mergethe first and second canonical rule sets in response to receiving thesecond canonical rule set.
 2. The device-implemented method of claim 1wherein the first canonical rule set is passed to or retrieved by theagent.
 3. The device-implemented method of claim 2 further comprisingrequesting the first canonical rule set from a rule repository.
 4. Thedevice-implemented method of claim 1 wherein the first canonical ruleset comprises agent goal specific canonical rules.
 5. Thedevice-implemented method of claim 1 wherein the agent is configured toretrieve the second canonical rule set.
 6. The device-implemented methodof claim 5 wherein the agent is further configured to retrieve thesecond canonical rule set from a rule repository in the executionenvironment.
 7. The device-implemented method of claim 1 wherein thesecond canonical rule set comprises domain and environment specificcanonical rules.
 8. A tangible computer readable medium havinginstructions stored thereon that, if executed by a computing device,cause the computing device to implement a method comprising: requestinga first set of canonical rules for an agent; retrieving a second set ofcanonical rules from an environment; causing the agent to merge thefirst and second canonical rule sets; compiling the merged canonicalrule set; creating a rule engine; and passing the compiled, mergedcanonical rule set to the rule engine.
 9. The tangible computer readablemedium of claim 8, wherein the method further comprises retrieving thesecond set of canonical rules from a rule repository.
 10. The tangiblecomputer readable medium of claim 9 wherein the rule repository is inthe execution environment in which the agent is being constructed. 11.The tangible computer readable medium of claim 9 wherein the secondcanonical rule set is retrieved by supplying the agent's domain.
 12. Thetangible computer readable medium of claim 10 wherein the agent isconfigured to construct the merged canonical rule set by taking a unionof the first canonical rule set and the second canonical rule set. 13.The tangible computer readable medium of claim 8, wherein the methodfurther comprises compiling the merged canonical rule set with a rulecompiler.
 14. The tangible computer readable medium of claim 8 whereinthe method further comprises supplying the compiled, merged canonicalrule set to a resident rule engine.
 15. A system comprising: a firstmemory; and a first processor configured to be communicably coupled tothe first memory, wherein the processor is configured to: construct anagent with two sets of canonical rules, by at least: retrieving a firstcanonical rule set for the agent; retrieving a second canonical rule setfrom an execution environment; causing the agent to merge the first andthe second canonical rule sets into a merged canonical rule set;requesting compilation of the merged canonical rule set; locating a ruleengine; supplying the rule engine with the compiled, merged canonicalrule set; and requesting a working memory from the rule engine.
 16. Thesystem of claim 15 wherein the first memory is configured to: store thecanonical merged rule set; store the compiled, merged canonical ruleset; and store the working memory from the rule engine.
 17. The systemof claim 15 further comprising: a second memory configured to store arule repository that contains canonical rules for achieving goals; and asecond processor configured to be communicably coupled to the secondmemory, wherein the second processor is configured to: attempt toretrieve, responsive to receiving a rule set query that includes agentgoals, an appropriate canonical rule set from the rule repository basedon the goals; and transmit a response containing the retrieved rule set,transmission of a response being caused by the receipt of the rule setquery.